<template>
  <div class="box">

    <div class="c-header">
      <ul class="header-ul">
        <li class="header-search">
          <img src="../assets/icon2/videoCamera.png" >
        </li>

        <li class="search">
          <div class="inp"  @click="goToSearch" >{{searchSuggest}}</div>
        </li>

        <li class="header-history">
          <img src="../assets/icon/menu.png" >
        </li>
      </ul>
      <span class="c-header-log"></span>


    </div>
    <div class="bat">
      <van-tabs v-model="active"
                animated
                swipeable
                background="#C74C3E"
                color="#fff"
                title-active-color="#fff"
                title-inactive-color="#E5AEA7"
      >
        <van-tab v-for="(index,key) in videotitlist" :title="index.name" :name="key" :key="key">

            <div class="box-video-text" v-for="(item,num) in videolist" :key="num">

              <div class="video">
                <video controls :poster="item.data.coverUrl" :src="item.data.urlInfo.url" class="video_item"></video>
              </div>
              <div class="text">
                {{item.data.title}}
              </div>
              <div class="information">
                <div class="left">
                  <div class="portrait"> <img :src="item.data.creator.avatarUrl" alt="" class="video_user_img"></div>
                  <div class="text2">{{item.data.creator.nickname}}</div>
                </div>
                <div class="right">
                  <span class="fabulous"></span>
                  <span class="comment"></span>
                  <span class="music"></span>
                  <span class="logo"></span>
                  <span class="number1">5661</span>
                  <span class="number2">89969</span>
                </div>
              </div>
            </div>

        </van-tab>
      </van-tabs>
    </div>

    <v-footer></v-footer>
  </div>

</template>

<script>
  import footer from "@/components/footer/"
  export default {
    name: "videos",
    data(){
      return {
        active: 0,
        videoid:'',
        searchSuggest: '',
        videotitlist: [{ id: '0' }],
        index: {},
        videolist: [],
      }
    },

    methods:{
      goToSearch() {
        this.$router.push({ name: 'search' });
      },

    },
    components: {

      'v-footer': footer,
    },
    created(){
      this.$http.get('http://localhost:3000/search/default')
        .then((res) => {
          this.searchSuggest = res.data.data.showKeyword;
        });
      this.$http.get('/api/video/group/list')
        .then((res) => {
          this.videotitlist = res.data.data.slice(0, 11);
          this.videoid = this.videotitlist[this.active].id;
          this.$http.get(`/api/video/group?id=${this.videoid}`)
            .then((rea) => {
              this.videolist = rea.data.datas;
            });
        });

    },

    watch: {
      active() {
        this.videoid = this.videotitlist[this.active].id;
        this.$http.get(`/api/video/group?id=${this.videoid}`)
          .then((rea) => {
            this.videolist = rea.data.datas;
          });
      },
    },
  }
</script>

<style scoped>
  .box{
    width: 100vw;
    min-height: 100vh;
    background: #ccc;
  }
  .c-header{
    position: fixed;
    z-index: 1000;
    width: 100vw;
    height: 50px;
    top: 0;
    background: #C74B3E;
    box-shadow: 0 2px 4px 0 rgba(0,0,0,0.1);
  }
  .header-ul{
    font-size: 0;
    height: 45px;
    margin-top: 5px;
    position: relative;
  }
  .header-ul li{
    display: inline-block;
    padding-left: 15px;
    font-size: 16px;
    color: #71777D;
    height: 40px;
    line-height: 40px;
  }
  .inp{
    width: 100%;
    height: 30px;
    line-height: 30px;
    border-radius: 20px;
    background: #CF6A60;
    text-indent: 80px;
    color: #E8B7B4;
    font-size: 14px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
  }
  ::-webkit-input-placeholder { /* WebKit browsers */
    color: #E2AAA5;
    font-size: 14px;
  }
  .c-header-log{
    width: 30px;
    height: 30px;
    display: inline-block;
    position: absolute;
    top: 22px;
    left: 105px;
    background: url("../assets/img/fangdajing.png") no-repeat;
    background-size: 18px;
  }
  .header-ul img{
    width: 24px;
    height: 20px;
  }
  .header-search{
    position: absolute;
    top: 10px;

  }
  .search{
    width: 72%;
    position: absolute;
    top: 10px;
    left: 35px;
  }
  .header-history{
    position: absolute;
    top: 10px;
    right: 18px;
  }
  .bat{
    width: 100vw;
    position: absolute;
    top: 48px;
    left: 0;
    margin-bottom: 50px;
   }
  .box-video-text{
    width: 100vw;
    height: 300px;
    background: #fff;
    padding: 5px;
    box-sizing: border-box;
  }
  .video{
    width: 96vw;
    height: 200px;
    border-radius: 5px;
    margin: 0 auto;
    overflow: hidden;

  }
  .video_item{
    width: 100%;
    height: 200px;
    margin-bottom: 30px;
  }
  .video_user_img{
    display: block;
    width: inherit;

  }
   .text{
    width: 100%;
    height: 50px;
     line-height: 50px;
    font-size: 16px;
    border-bottom: 2px solid #F7F8F9;
     display: -webkit-box;
     -webkit-box-orient: vertical;
     -webkit-line-clamp: 1;
     overflow: hidden;

   }
   .information{
     width: 100vw;
     height: 40px;

   }
  .left{
    width: 45%;
    height: 40px;
    float: left;
  }
  .left .text2{
    width: 130px;
    height: 40px;
    line-height: 40px;
    font-size: 13px;
    float: left;
    color: #7A7A7B;
    margin-left: 5px;
  }
  .portrait{
    width: 25px;
    height: 25px;
    border-radius: 45px;
    margin-top: 7px;
    margin-left: 8px;
    float: left;
    overflow: hidden;
  }
  .right{
    width: 55%;
    height: 40px;
    float: left;
    position: relative;
  }
  .fabulous{
    display: block;
    width: 30px;
    height: 30px;
    position: absolute;
    top: 5px;
    left: 5px;
    background: url("../assets/icon2/zan.png") no-repeat 5px;
    background-size: 20px;
  }
  .comment{
    display: block;
    width: 30px;
    height: 30px;
    background: #795da3;
    position: absolute;
    top: 5px;
    left: 65px;
    background: url("../assets/icon/pinglun.png") no-repeat 5px;
    background-size: 20px;
  }
  .music{
    display: block;
    width: 30px;
    height: 30px;
    background: #795da3;
    position: absolute;
    top: 5px;
    left: 120px;
    background: url("../assets/icon2/musicIcon.png") no-repeat 5px;
    background-size: 20px;
  }
  .logo{
    display: block;
    width: 30px;
    height: 30px;
    background: #795da3;
    position: absolute;
    top: 5px;
    right: 10px;
    background: url("../assets/icon/more.png") no-repeat 5px;
    background-size: 20px;
  }
  .number1{
    display: block;
    width: 35px;
    height: 15px;
    color: #9C9D9E;
    background: #fff;
    position: absolute;
    font-size: 10px;
    top: 5px;
    left: 20px;
  }
  .number2{
    display: block;
    width: 35px;
    height: 12px;
    background: #fff;
    color: #9C9D9E;
    position: absolute;
    font-size: 10px;
    top: 5px;
    left: 83px;
  }
</style>
